package com.aispeech.jarpc.op.sscvad;

import java.io.IOException;

import com.aispeech.jarpc.TextBin;
import com.aispeech.jarpc.op.AbstractRequest;

public class SscVadRequest extends AbstractRequest {
    private final static String REQ_TMPL = "{\"op\":\"ssc-vad\",\"vad_bin_path\":\"%s\",\"ssc_bin_fn\":\"%s\",\"audio_path\":\"%s\",\"speakers\":%d,\"pause_time\":0,\"rpc_path\":\"%s\"}";
    
    private String vadBinPath;
    private String sscBinFn;
    private String audioPath;
    private int speakers;
    private String rpcPath;

    public SscVadRequest(String vadBinPath, String sscBinFn, String audioPath,  int speakers, String rpcPath) {
        this.vadBinPath = vadBinPath;
        this.sscBinFn = sscBinFn;
        this.audioPath = audioPath;
        this.speakers = speakers;
        this.rpcPath = rpcPath;
    }

    public TextBin toJsonBin() throws IOException {
        String json = toJson();
        return new TextBin(json, null);
    }

    @Override
    public String toJson() {
        return String.format(REQ_TMPL, vadBinPath, sscBinFn, audioPath, speakers, rpcPath);
    }

    @Override
    public String OpType() {
        return "ssc-vad";
    }
}
